package io.renren.utils;



import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 判断时间大小
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2016-11-15
 */
public class ShijianUtil {

    /**
     * 当前时间和传入时间对比
     */
    public static int daToXiao(Date longTime) {

        int flag;
        Date time = null;
        Date date = new Date();//获得系统时间.
        SimpleDateFormat sdf = new SimpleDateFormat(" yyyy-MM-dd");
        String nowTime = sdf.format(date);
        try {
            time = sdf.parse(nowTime);
        } catch (Exception e) {
            e.printStackTrace();
        }
        flag = time.compareTo(longTime);//对比大小
        return flag;
    }

    /**
     * 当前时间精确到天
     *
     * @return
     */
    public static Date shijian() {

        int flag;
        Date time = null;
        Date date = new Date();//获得系统时间.
        SimpleDateFormat sdf = new SimpleDateFormat(" yyyy-MM-dd");
        String nowTime = sdf.format(date);

        try {
            time = sdf.parse(nowTime);
            return time;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return time;
    }
}
